package top.yueyazhui.dds.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.yueyazhui.dds.datasource.DataSourceType;

import javax.servlet.http.HttpSession;

@RestController
@RequestMapping("/system/config")
public class DataSourceController {

    public final static Logger LOGGER = LoggerFactory.getLogger(DataSourceController.class);

    /**
     * 修改数据源
     * @param dataSourceType
     */
    @PostMapping("/data_source_type")
    public void setDataSourceType(String dataSourceType, HttpSession session) {
        session.setAttribute(DataSourceType.DATA_SOURCE_SESSION_KEY, dataSourceType);
        LOGGER.info("数据源切换为：{}", dataSourceType);
    }
}
